﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
using System.Globalization;
using Nivdal.AuxCode;
using System.Text;

namespace Nivdal
{
    public partial class NationalTeamsCurrentMatches : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Title = Resources.Resource.NationalTeamsMatches_PageTitle + ", " + Resources.Resource.Country_PageTitle;


        }

        protected void AddSelectedToLive(object sender, EventArgs e)
        {
            bool Added = false;
            foreach (GridViewRow r in NationalTeamsMatchesGridview.Rows)
            {
                if (r.RowType == DataControlRowType.DataRow)
                {
                    try
                    {
                        if ((r.FindControl("AddToLivePanel") as Panel).Visible)
                        {
                            if ((r.FindControl("AddLiveCheckBox") as CheckBox).Checked)
                            {
                                AddMatchToLive((r.FindControl("MatchIdHiddenField") as HiddenField).Value);
                                Added = true;
                            }
                        }
                    }
                    catch { }
                }
            }
            if (Added)
                Response.Redirect("~/Live.aspx");

        }

        protected void AddToLive(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "AddToLive")
            {
                AddMatchToLive(e.CommandArgument.ToString());
                Response.Redirect("~/Live.aspx");
            }
        }

        private void AddMatchToLive(string MatchId)
        {
            OnlineUser ou = (OnlineUser)Session["User"];
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            GND.ExecNivdalSQL("UserId", "MatchId", "Nivdal_LiveAddMatchToLive", ou.UserId, MatchId);
        }

        protected override void InitializeCulture()
        {
            OnlineUser ou = (OnlineUser)Session["User"];
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(ou.UICulture);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ou.Culture);
        }
    }
}